import request from '@/utils/request.js'

export const uploadSignService = fileSize =>
  request.get(`/api/file/private/upload-sign?fileSize=${fileSize}`)

export const skipUploadService = (filename, identifier, parentId, fileSize) =>
  request.post(`/api/file/private/skip-upload`, { filename, identifier, parentId, fileSize })

export const fileListService = parentId =>
  request.get(`/api/file/private/list?parentId=${parentId}`)

export const createFolderService = (parentId, folderName) =>
  request.post(`/api/file/private/folder`, { parentId, folderName })

export const breadcrumbsService = parentId =>
  request.get(`/api/file/private/breadcrumbs?fileId=${parentId}`)

export const renameService = (fileId, newFilename) =>
  request.post(`/api/file/private/rename`, { fileId, newFilename })

export const recycleFileService = fileIds => request.post(`/api/file/private/recycle`, { fileIds })

export const getFolderTreeService = () => request.get(`/api/file/private/folder/tree`)

export const transferFilesService = (fileIds, targetParentId) =>
  request.post(`/api/file/private/transfer`, {
    fileIds,
    targetParentId
  })

export const getDownloadUrlService = fileId =>
  request.get(`/api/file/private/download?fileId=${fileId}`)

export const getPreviewUrlService = fileId =>
  request.get(`/api/file/private/preview?fileId=${fileId}`)
